using System;
using System.Windows.Forms;

namespace OziMonitoring
{
	/// <summary>
	/// Class to control status bar
	/// </summary>
	public class StatusMessageControl
	{
		/// <summary>
		/// Control to control
		/// </summary>
		private Control messageControl = null;
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="_messageControl"></param>
		public StatusMessageControl(Control _messageControl)
		{
			messageControl = _messageControl;
		}

		/// <summary>
		/// Set info text
		/// </summary>
		/// <param name="message"></param>
		public void InfoMessage(string message)
		{
			if (messageControl != null)
				messageControl.Text = message;
		}

		/// <summary>
		/// Set error text
		/// </summary>
		/// <param name="message"></param>
		public void ErrorMessage(string message)
		{
			if (messageControl != null)
				messageControl.Text = message;
		}

		/// <summary>
		/// Set error text
		/// </summary>
		/// <param name="ex"></param>
		public void ErrorMessage(Exception ex)
		{
			if (messageControl != null)
				messageControl.Text = ex.Message +
				                      System.Environment.NewLine +
				                      System.Environment.NewLine +
				                      ExceptionHandler.GetFullExceptionDescription(ex, false);
		}

		/// <summary>
		/// Clear ststus area
		/// </summary>
		public void Clear()
		{
			if (messageControl != null)
				messageControl.Text = String.Empty;
		}
	}
}